<!DOCTYPE html>
<html>
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <meta http-equiv="X-UA-Compatible" content="ie=edge" />
    <meta name="referrer" content="no-referrer" />
    <meta
      name="description"
      content="汇融名企是面向全国商家服务的大型互联网平台，为商家提供流量扶持，引导品牌曝光；为消费者提供风云榜单，招商加盟，引导实现消费，达成合作，上汇融名企实现共赢。"
    />
    <title>更多榜单-汇融名企</title>
    <link rel="stylesheet" href="./css/common.css" />
    <link rel="stylesheet" href="./css/paging.css" />
    <style>
      #category {
        background: #fff;
        box-shadow: 0px 3px 10px 0 #d9d9d9;
        min-height: 84px;
      }
      #card-wrapper {
        min-height: 637px;
      }
      .content {
        max-width: 1500px;
        margin: 20px auto;
      }
      .card {
        width: 320px;
        height: 262px;
        background: rgba(255, 255, 255, 1);
        border: 3px solid rgba(244, 244, 244, 1);
        padding: 22px 19px 0 19px;
        margin-right: 14px;
        display: inline-block;
        position: relative;
        transition: 0.2s ease-in-out;
        margin-bottom: 40px;
      }
      .card:hover {
        border-color: rgba(248, 62, 37, 1);
      }
      .card-img {
        width: 319px;
        height: 182px;
        margin: auto;
        cursor: pointer;
      }
      .card-time {
        width: 319px;
        height: 36px;
        background: #000000;
        opacity: 0.56;
        position: absolute;
        bottom: 80px;
        text-align: center;
        font-size: 14px;
        font-weight: 400;
        color: rgba(255, 255, 255, 1);
        line-height: 36px;
      }
      .card-text {
        font-size: 18px;
        font-family: Microsoft YaHei;
        font-weight: 400;
        color: rgba(51, 51, 51, 1);
        text-indent: 10px;
        margin-top: 23px;
        cursor: pointer;
      }
      .card-tag {
        height: 30px;
        width: 150px;
        background: url('./image/picture/rankingList_card_tag.png');
        position: absolute;
        right: 19px;
        top: 20px;
        transition: 0.2s ease-in-out;
        font-size: 14px;
        font-weight: 400;
        color: rgba(255, 255, 255, 1);
        line-height: 30px;
        text-indent: 13px;
      }
      .not-found {
        height: 100%;
        font-size: 18px;
        font-weight: bold;
        text-align: center;
        line-height: 400px;
        display: none;
      }
      .ranking-search {
        width: 301px;
        height: 44px;
        background: rgba(255, 255, 255, 1);
        border: 1px solid rgba(219, 164, 72, 1);
        box-shadow: 0px 5px 5px 0px rgba(0, 0, 0, 0.05);
        border-radius: 22px;
        padding: 0 40px;
        margin: 45px auto;
      }
      .ranking-search input {
        border: none;
        outline: none;
        height: 42px;
        width: 276px;
        background: #fff;
      }
      .ranking-search img {
        display: inline-block;
        vertical-align: sub;
        position: relative;
        top: -2px;
        cursor: pointer;
      }
      #header-page {
        background: #fff;
      }
    </style>
  </head>
  <body>
    <!-- <div id="header-page"></div> -->
    <!--#include virtual="/header.html" -->
    <div class="content-wrapper">
      <div id="category"></div>
      <div class="content">
        <div class="ranking-search-wrapper">
          <div class="ranking-search">
            <input
              id="search-ranking"
              type="text"
              placeholder="请输入排行榜名称"
            />
            <img id="search-icon" src="./image/icon/search.png" />
          </div>
        </div>
        <div id="card-wrapper">
          <div class="not-found" id="not-found">暂无数据</div>
        </div>
        <!-- <div class="clear"></div> -->
        <div id="page" class="page_div"></div>
        <!-- <div class="card">
          <div class="card-img">
            <img class="card-img" src="" />
          </div>
          <div class="card-tag">活动行业：建材行业</div>
          <div class="card-time">活动结束时间：2019-09-09</div>
          <div class="card-text need-text-overflow">
            长沙奶茶房河北石家庄市裕华东路店...
          </div>
        </div> -->
      </div>
    </div>
    <!-- <div id="footer-page"></div>  -->
    <!--#include virtual="/footer.html" -->
    <script src="./js/jquery-1.11.0.min.js"></script>
    <script src="./js/category.js"></script>
    <script src="./js/jquery.my-message.1.1.js"></script>
    <script src="./js/utils.js"></script>
    <!-- <script src="http://pv.sohu.com/cityjson?ie=utf-8"></script> -->
    <script src="./js/api.js"></script>
    <script src="./js/LAreaData2.js"></script>
    <script src="./js/paging.js"></script>
    <script type="text/javascript">
      $(function () {
        var historyPath
        if (
          document.referrer &&
          (document.referrer.indexOf('chmqlive') != -1 ||
            document.referrer.indexOf('39.107.45.63') != -1)
        ) {
          historyPath = document.referrer
            .split('http://')[1]
            .split('/')[1]
            .split('.')[0]
        } else {
          historyPath = ''
        }
        // var flag = historyPath != 'rankingList' && historyPath != 'rankingPage'
        // if (!document.referrer || flag) {
        //   sessionStorage.removeItem('title')
        // }
        if (historyPath != 'rankingList') {
          sessionStorage.removeItem('type_pid')
          sessionStorage.removeItem('type_ids')
        }
        $('#search-icon').click(function () {
          var title = $('#search-ranking').val()
          sessionStorage.setItem('title', title)
          getCard(title)
        })
        var timer = ''
        $('#search-ranking').keydown(function (e) {
          if (timer) {
            return false
          }
          var that = this
          var title = $(that).val()
          if (event.keyCode == 13 && title) {
            timer = setTimeout(function () {
              sessionStorage.setItem('title', title)
              getCard(title)
              timer = ''
            }, 200)
          }
        })
        getData()
      })

      function getCard(title) {
        var params = {
          city_id: sessionStorage.getItem('city_id'),
          page: 1,
        }
        if (sessionStorage.getItem('type_pid')) {
          params.type_id = sessionStorage.getItem('type_pid')
        }
        if (sessionStorage.getItem('type_ids')) {
          params.type_ids = sessionStorage.getItem('type_ids')
        }
        params.title = title
        var api = new ajax('GET', '/api/home/rankingSelect', params)
        api.then(function (res) {
          $('.card').remove()
          var data = JSON.parse(res).data
          initCard(data.list, 4, $('#card-wrapper'))
          if (data.page <= 1) {
            $('#page').hide()
          } else {
            $('#page').show()
          }
          if (data.total === 0) {
            $('#not-found').show()
          } else {
            $('#not-found').hide()
          }
        })
      }
      function init(data) {
        // $('#header-page').load('header.html')
        // $('#footer-page').load('footer.html')
        $('#category').load('category.html', function () {
          data.type.unshift({ id: 0, ind_name: '全部' })
          initTypeItem(
            data.type,
            sessionStorage.getItem('type_pid') || 0,
            $('#category-container'),
            handleCategoryClick
          )
        })
        initCard(data.list, 4, $('#card-wrapper'))
        $('#page').paging({
          pageNo: data.page,
          totalPage: data.page_num,
          totalSize: data.total,
          callback: function (num) {
            changePage(num)
          },
        })
        if (data.page_num <= 1) {
          $('#page').hide()
        }
        if (data.total === 0) {
          $('#not-found').show()
        }
      }
      function initCard(data, num, parent) {
        var el = ''
        for (key in data) {
          var currentData = data[key]
          var flag = (+key + 1) % num
          var temp = [
            '<div class="card" ' +
              (flag ? '' : 'style="margin-right:0;"') +
              '>',
            '  <div class="card-img" id="' + currentData.id + '">',
            '    <img class="card-img" src="' +
              (currentData.images.indexOf('http') > -1
                ? currentData.images
                : URL + currentData.images) +
              '" />',
            '  </div>',
            '  <div class="card-tag">活动行业：' +
              currentData.ind_name +
              '</div>',
            '  <div class="card-time">活动结束时间：' +
              currentData.end_time +
              '</div>',
            '  <div class="card-text need-text-overflow" id="' +
              currentData.id +
              '">',
            currentData.title,
            '  </div>',
            '</div>',
          ].join('')
          el += temp
        }
        parent.append(el)
        $('.card').hover(
          function () {
            $(this)
              .find('.card-tag')
              .css(
                'background',
                'url("./image/picture/rankingList_card_tag_active.png")'
              )
          },
          function () {
            $(this)
              .find('.card-tag')
              .css(
                'background',
                'url("./image/picture/rankingList_card_tag.png")'
              )
          }
        )
        $('.card-img').click(handleClick)
        $('.card-text').click(handleClick)
      }
      function getData() {
        var params = getURLParams()
        var targetParams = {
          city_id: sessionStorage.getItem('city_id'),
        }
        if (sessionStorage.getItem('type_pid')) {
          targetParams.type_id = sessionStorage.getItem('type_pid')
        }
        if (sessionStorage.getItem('type_ids')) {
          targetParams.type_ids = sessionStorage.getItem('type_ids')
        }
        if (params.page) {
          targetParams.page = params.page
        }
        if (sessionStorage.getItem('title')) {
          targetParams.title = sessionStorage.getItem('title')
          $('#search-ranking').val(targetParams.title)
        }
        var api = new ajax('GET', '/api/home/rankingSelect', targetParams)
        api.then(function (res) {
          init(JSON.parse(res).data)
        })
      }
      function handleClick() {
        var id = $(this).attr('id')
        sessionStorage.removeItem('type_pid')
        sessionStorage.removeItem('type_ids')
        go('rankingDetail.html?list_id=' + id)
      }
      function handleCategoryClick(id) {
        var params = {
          city_id: sessionStorage.getItem('city_id'),
          page: 1,
        }
        if (sessionStorage.getItem('type_pid')) {
          params.type_id = sessionStorage.getItem('type_pid')
        }
        if (sessionStorage.getItem('type_ids')) {
          params.type_ids = sessionStorage.getItem('type_ids')
        }
        if (sessionStorage.getItem('title')) {
          params.title = sessionStorage.getItem('title')
        }
        var api = new ajax('GET', '/api/home/rankingSelect', params)
        api.then(function (res) {
          $('.card').remove()
          var data = JSON.parse(res).data
          initCard(data.list, 4, $('#card-wrapper'))
          if (+data.page_num <= 1) {
            $('#page').hide()
          } else {
            $('#page').show()
            $('#page').paging({
              pageNo: data.page,
              totalPage: data.page_num,
              totalSize: data.total,
              callback: function (num) {
                changePage(num)
              },
            })
          }
          if (data.total === 0) {
            $('#not-found').show()
          } else {
            $('#not-found').hide()
          }
        })
      }
    </script>
  </body>
</html>
